﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace Infusion.Silverlight.Controls.OpenOfficeXML
{
    #region : PageSize :
    public abstract class PageSize
    {
        #region Class Variables...
        private PageOrientation orientation = PageOrientation.Portrait;
        #endregion

        #region Methods...
        #region GetWidth
        public double GetWidth(DocumentUnit unit)
        {
            return OpenXMLHelper.ConvertPointsToUnits(unit, orientation == PageOrientation.Portrait ? PointWidth : PointHeight);
        }
        #endregion

        #region GetHeight
        public double GetHeight(DocumentUnit unit)
        {
            return OpenXMLHelper.ConvertPointsToUnits(unit, orientation == PageOrientation.Portrait ? PointHeight : PointWidth);
        }
        #endregion
        #endregion

        #region Properties...
        #region PointWidth
        public abstract int PointWidth { get; }
        #endregion

        #region PointHeight
        public abstract int PointHeight { get; }
        #endregion

        #region PixelWidth
        public double PixelWidth
        {
            get
            {
                return Convert.ToDouble(orientation == PageOrientation.Portrait ? PointWidth : PointHeight) *
                    OpenXMLHelper.PointsToPixelsMultiplier;
            }
        }
        #endregion

        #region PixelHeight
        public double PixelHeight
        {
            get
            {
                return Convert.ToDouble(orientation == PageOrientation.Portrait ? PointHeight : PointWidth) *
                    OpenXMLHelper.PointsToPixelsMultiplier;
            }
        }
        #endregion

        #region Orientation
        public PageOrientation Orientation
        {
            get { return orientation; }
            set { orientation = value; }
        }
        #endregion
        #endregion
    }
    #endregion

    #region PageSize Implementations...
    #region : PageSizeLetter :
    public class PageSizeLetter : PageSize
    {
        // 8.5" x 11"

        public override int PointWidth { get { return 612; } }
        public override int PointHeight { get { return 792; } }
    }
    #endregion

    #region : PageSizeLegal :
    public class PageSizeLegal : PageSize
    {
        // 8.5" x 14"

        public override int PointWidth { get { return 612; } }
        public override int PointHeight { get { return 1008; } }
    }
    #endregion
    #endregion
}
